package com.gaohe.official.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gaohe.common.log.annotation.Log;
import com.gaohe.common.log.enums.BusinessType;
import com.gaohe.common.security.annotation.RequiresPermissions;
import com.gaohe.official.domain.FmMine;
import com.gaohe.official.service.IFmMineService;
import com.gaohe.common.core.web.controller.BaseController;
import com.gaohe.common.core.web.domain.AjaxResult;
import com.gaohe.common.core.utils.poi.ExcelUtil;
import com.gaohe.common.core.web.page.TableDataInfo;

/**
 * 我的栏目Controller
 * 
 * @author ruoyi
 * @date 2025-06-03
 */
@RestController
@RequestMapping("/mine")
public class FmMineController extends BaseController
{
    @Autowired
    private IFmMineService fmMineService;

    /**
     * 查询我的栏目列表
     */
    @RequiresPermissions("official:mine:list")
    @GetMapping("/list")
    public TableDataInfo list(FmMine fmMine)
    {
        startPage();
        List<FmMine> list = fmMineService.selectFmMineList(fmMine);
        return getDataTable(list);
    }

    /**
     * 导出我的栏目列表
     */
    @RequiresPermissions("official:mine:export")
    @Log(title = "我的栏目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FmMine fmMine)
    {
        List<FmMine> list = fmMineService.selectFmMineList(fmMine);
        ExcelUtil<FmMine> util = new ExcelUtil<FmMine>(FmMine.class);
        util.exportExcel(response, list, "我的栏目数据");
    }

    /**
     * 获取我的栏目详细信息
     */
    @RequiresPermissions("official:mine:query")
    @GetMapping(value = "/{mineId}")
    public AjaxResult getInfo(@PathVariable("mineId") Long mineId)
    {
        return success(fmMineService.selectFmMineByMineId(mineId));
    }

    /**
     * 新增我的栏目
     */
    @RequiresPermissions("official:mine:add")
    @Log(title = "我的栏目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FmMine fmMine)
    {
        return toAjax(fmMineService.insertFmMine(fmMine));
    }

    /**
     * 修改我的栏目
     */
    @RequiresPermissions("official:mine:edit")
    @Log(title = "我的栏目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FmMine fmMine)
    {
        return toAjax(fmMineService.updateFmMine(fmMine));
    }

    /**
     * 删除我的栏目
     */
    @RequiresPermissions("official:mine:remove")
    @Log(title = "我的栏目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mineIds}")
    public AjaxResult remove(@PathVariable Long[] mineIds)
    {
        return toAjax(fmMineService.deleteFmMineByMineIds(mineIds));
    }
}
